snippet scaffold
alias #!
	#!/bin/bash
	# ${1:<name>} v${2:0.1.0}
	# (c) ${3:`strftime("%Y")`} ${4:Maddison Hellstrom} - ${5:MIT} License
	# ${6:github.com/b0o/}

	# bash "strict mode"
	# http://redsymbol.net/articles/unofficial-bash-strict-mode/
	# exit on fail
	set -e
	# prevent shell expansion of unset params
	set -u
	# fail upon any failure in a pipeline
	set -o pipefail

	IFS=$'\n\t'

	NAME="${1}"
	VERSION="${2}"
	COPYRIGHTYEAR="${3}"
	AUTHOR="${4}"
	LICENSE="${5}"
	URL="${6}"

	BASEDIR=$(dirname "\$0")
	PROG=$(basename "\$0")

	QUIET=0
	VERBOSE=0

	function main() {
		local usage
		usage="$NAME $VERSION
	(c) $(date +%Y) $AUTHOR
	$URL
	MIT License

	USAGE:
	  $PROG [-h] [-V|q]

	OPTIONS:

	  -h        Display this message and exit.

	  -q        Run in quiet mode

	  -V        Run in verbose mode - overrides quiet mode

	  -D        Show debug information

		"

		local OPTIND OPTARG
		while getopts 'VhqD' option; do
			case "$option" in
			V)
				VERBOSE=1
				;;
			h)
				echo "${usage}"
				exit 1
				;;
			q)
				QUIET=1
				;;
			D)
				set -x
				;;
			\?)
				printf "Error: illegal option: -%s\\n%s" "${OPTARG}" "$usage"
				exit 1
				;;
			esac
		done
		shift $((OPTIND - 1))

		${0}
		${5:TARGET}
	}

	# Logging utility stuff
	# Text Reset
	export RCol='\e[0m'

	# Regular
	export Bla='\e[0;30m'
	export Red='\e[0;31m'
	export Gre='\e[0;32m'
	export Yel='\e[0;33m'
	export Blu='\e[0;34m'
	export Pur='\e[0;35m'
	export Cya='\e[0;36m'
	export Whi='\e[0;37m'

	# Bold
	export BBla='\e[1;30m'
	export BRed='\e[1;31m'
	export BGre='\e[1;32m'
	export BYel='\e[1;33m'
	export BBlu='\e[1;34m'
	export BPur='\e[1;35m'
	export BCya='\e[1;36m'
	export BWhi='\e[1;37m'

	# Underline
	export UBla='\e[4;30m'
	export URed='\e[4;31m'
	export UGre='\e[4;32m'
	export UYel='\e[4;33m'
	export UBlu='\e[4;34m'
	export UPur='\e[4;35m'
	export UCya='\e[4;36m'
	export UWhi='\e[4;37m'

	# High Intensity
	export IBla='\e[0;90m'
	export IRed='\e[0;91m'
	export IGre='\e[0;92m'
	export IYel='\e[0;93m'
	export IBlu='\e[0;94m'
	export IPur='\e[0;95m'
	export ICya='\e[0;96m'
	export IWhi='\e[0;97m'

	# BoldHigh Intens
	export BIBla='\e[1;90m'
	export BIRed='\e[1;91m'
	export BIGre='\e[1;92m'
	export BIYel='\e[1;93m'
	export BIBlu='\e[1;94m'
	export BIPur='\e[1;95m'
	export BICya='\e[1;96m'
	export BIWhi='\e[1;97m'

	# Background
	export On_Bla='\e[40m'
	export On_Red='\e[41m'
	export On_Gre='\e[42m'
	export On_Yel='\e[43m'
	export On_Blu='\e[44m'
	export On_Pur='\e[45m'
	export On_Cya='\e[46m'
	export On_Whi='\e[47m'

	# High Intensity Backgrounds
	export On_IBla='\e[0;100m'
	export On_IRed='\e[0;101m'
	export On_IGre='\e[0;102m'
	export On_IYel='\e[0;103m'
	export On_IBlu='\e[0;104m'
	export On_IPur='\e[0;105m'
	export On_ICya='\e[0;106m'
	export On_IWhi='\e[0;107m'

	# Status Messages
	export Ifo="${IGre}[ INFO]${RCol} "
	export Wrn="${IYel}[ WARN]${RCol} "
	export Err="${IRed}[ERROR]${RCol} "
	export Dbg="${ICya}[DEBUG]${RCol} "

	logindent_str="  "
	logindent_lvl=0
	function logindent() {
		local op arg
		if [[ ${#@} == 1 ]]; then
			op="="
			arg=$1
		else
			op="$1"
			arg="$2"
		fi
		case "$op" in
		"+")
			((logindent_lvl += arg)) || true
			;;
		"-")
			((logindent_lvl -= arg)) || true
			;;
		"=")
			logindent_lvl=$arg
			;;
		esac
		if [[ $logindent_lvl -lt 0 ]]; then
			log "$Wrn" "attempting to set negative logindent_lvl ${Yel}${logindent_lvl}${RCol}"
			logindent_lvl=0
		fi
	}

	function log() {
		local lvl
		lvl="$1"
		shift
		[[ $QUIET == 1 ]] && return
		[[ $lvl == "$Dbg" ]] && [[ $VERBOSE == 0 ]] && return

		local indent
		indent=""
		if [[ $logindent_lvl -gt 0 ]]; then
			indent=$(printf "${logindent_str}%.0s" $(seq 1 "$logindent_lvl"))
		fi

		while read -r line; do
			echo -e "${lvl}${indent}${line}" | paste -sd ' ' >&2
		done <<< "$@"
	}

	main "${@}"
